# 这个Strategy是给系统开发使用的，而不提供给用户
# 系统功能使用此接口类

from IStrategyContext import IStrategyContext


class StrategyContext(IStrategyContext):
    public_context = None
    strategy = None
    cur_strategy_order_id = 0

    def __init__(self, strategy):
        self.strategy = strategy
        self.cur_strategy_order_id = 0

    def put_md(self, md):
        pass

    def put_event(self, event):
        pass

    def log_message(self, message):
        self.public_context.log_message(message)

    def send_order(self, order):
        order.strategy_name = self.strategy_name
        self.public_context.send_order(order)

    def get_position(self):
        return self.public_context.get_position(self.strategy_name)

    def get_strategy_order_id(self):
        self.cur_strategy_order_id += 1
        return 'STG_{}_order{}'.format(self.strategy_name, str(self.cur_strategy_order_id))

    def start(self):
        pass

    def join(self):
        pass

    @property
    def strategy_name(self):
        return self.strategy.strategy_name

